package ecweb.dao;

import ecweb.dal.DatabaseSession;
import ecweb.domain.User;
import ecweb.exception.DatabaseException;

public interface IUserDao {

	// SELECT * FROM users WHERE ID = ? LIMIT 0,1
	User getUserById(DatabaseSession dbses, long id)
			throws DatabaseException;
	
	// SELECT * FROM users WHERE Username = ? LIMIT 0,1
	User getUserByUsername(DatabaseSession dbses, String username)
			throws DatabaseException;
	
	// SELECT COUNT(*) FROM users WHERE Username = ?
	boolean checkUserExistenceByUsername(DatabaseSession dbses, String username)
			throws DatabaseException;
	
	// UPDATE users SET Password = ?, RealName = ?, ... WHERE ID = ?
	boolean updateUserById(DatabaseSession dbses, User User)
			throws DatabaseException;
	
	// INSERT INTO users(....) VALUES (?, ?, ....)
	// SELECT LAST_INSERT_ID()
	void addUser(DatabaseSession dbses, User User)
			throws DatabaseException;
	
	// DELETE FROM users WHERE ID = ?
    void deleteUserById(DatabaseSession dbses, long id)
			throws DatabaseException;
	
}
